package com.my.chapter14;

public class practice20 {
    public static void display(String msg, Object[] vals) {
        System.out.println(msg);
        for(Object val : vals)
            System.out.println(" " + val);
    }
    public static void
    classInfo(Class<?> c) throws Exception {
        System.out.println("c.getName(): " + c.getName());
        System.out.println("c.getPackage(): " + c.getPackage());
        System.out.println("c.getSuperclass(): " + c.getSuperclass());
        display("c.getDeclaredClasses()",
                c.getDeclaredClasses());//得到该类所有的内部类，除去父类的
        display("c.getClasses()", c.getClasses());//得到该类及其父类所有的public的内部类。
        display("c.getInterfaces()", c.getInterfaces());
        display("c.getDeclaredMethods()",
                c.getDeclaredMethods());//该方法是获取本类中的所有方法，包括私有的(private、protected、默认以及public)的方法
        display("c.getMethods()", c.getMethods());//该方法是获取本类以及父类或者父接口中所有的公共方法(public修饰符修饰的)
        display("c.getDeclaredConstructors()",
                c.getDeclaredConstructors());
        display("c.getConstructors()", c.getConstructors());
        display("c.getDeclaredFields()",
                c.getDeclaredFields());
        display("c.getFields()", c.getFields());
        if(c.getSuperclass() != null) {
            System.out.println("Base class: --------");
            classInfo(c.getSuperclass());
        }
        System.out.println("End of " + c.getName());
    }

    public static void main(String[] args) throws Exception {
        classInfo(SubClass.class);
    }
}

interface One{
    void display();
}

interface Two{
    void go();
}

class BaseOne{
    String s;
    public void f(){}
    public BaseOne(){}
    public BaseOne(String s){ this.s = s; }
}

class SubClass extends BaseOne implements One,Two{
    String str;
    int i;

    public SubClass(){}
    public SubClass(String s){super(s); this.str = s;}

    @Override
    public void display() {}

    @Override
    public void go() {}
}

